local zuoxing = fk.CreateSkill {

  name = "joy__zuoxing",

  tags = {  },

}



zuoxing:addEffect("viewas", {
  name = "joy__zuoxing",
  prompt = "#zuoxing",
  interaction = function(self,player)
    local names, all_names = {} , {}
    for _, id in ipairs(Fk:getAllCardIds()) do
      local card = Fk:getCardById(id)
      if card:isCommonTrick() and not card.is_derived and not table.contains(all_names, card.name) then
        table.insert(all_names, card.name)
        local to_use = Fk:cloneCard(card.name)
        if player:canUse(to_use) and not player:prohibitUse(to_use) then
          table.insert(names, card.name)
        end
      end
    end
    if #names == 0 then return false end
    return UI.ComboBox {choices = names, all_choices = all_names}
  end,
  enabled_at_play = function(self, player)
    return
      player:usedSkillTimes(zuoxing.name, Player.HistoryPhase) == 0 and
      table.find(Fk:currentRoom().alive_players, function(p)
        return table.find({ p.general, p.deputyGeneral }, function(name) return string.find(name, "joy__godguojia") end) and p.maxHp > 1
      end)
  end,
  card_filter = Util.FalseFunc,
  view_as = function(self, player,cards)
    if not self.interaction.data then return end
    local card = Fk:cloneCard(self.interaction.data)
    card.skillName = zuoxing.name
    return card
  end,
  before_use = function(self, player)
    local room = player.room
    local firstGodGuojia = table.filter(room:getAlivePlayers(), function(p)
      return table.find({ p.general, p.deputyGeneral }, function(name) return string.find(name, "joy__godguojia") end) and p.maxHp > 1
    end)
    if firstGodGuojia then
      room:changeMaxHp(firstGodGuojia[1], -1)
    end
  end,
})

return zuoxing